const state = () => {
  return {
    userInfo: null,
    userCell: 'userCell',
  }
}
const getters = () => {
  return {
    userInfo(state) {
      if (state.userInfo) {
        return state.userInfo
      } else {
        return localStorage.getItem('userInfo')
      }
    },
  }
}
const mutations = {
  SET_USERINFO(state, userInfo) {
    state.userInfo = userInfo
    localStorage.setItem('userInfo', JSON.stringify(state.userInfo))
  },
  CLEAR_USERINFO(state) {
    state.userInfo = null
    localStorage.setItem('userInfo', null)
  },
}

export default {
  namespace: true,
  state,
  mutations,
}
